<?php 
/**
 * GioCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@ninhgio.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2010-2011 GioCMS (http://cms.ninhgio.com)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @author		NinhGio - ninhgio@gmail.com
 * @since		1.0
 * @version		$Id:$
 */
?>
<div id="menu">
	<div id="left"></div>
	<div id="right"></div>
	<ul>
		<li>
			<a href="javascript: void(0);"><span><?php echo $this->TRANSLATOR->translator('common_admin_title', 'core'); ?></span></a>
		</li>
	</ul>
	<div class="clear"></div>
</div>
<div id="submenu">
	<div class="fl">
		<div class="module buttons">
			<a class="module_button" href="<?php echo $this->url('core_dashboard_index'); ?>"><small class="icon home"></small><span><?php echo $this->TRANSLATOR->translator('common_dashboard', 'core'); ?></span></a>
		</div>
		<?php if ($this->ACL->isAllowed('config', 'website', 'core')) : ?>
		<div class="module buttons">
			<a class="module_button" href="<?php echo $this->url('core_website_config'); ?>"><small class="icon settings"></small><span><?php echo $this->TRANSLATOR->translator('common_settings', 'core'); ?></span></a>
		</div>
		<?php endif; ?>
		<div class="module buttons">
			<a class="dropdown_button" href=""><small class="icon crosshair"></small><span><?php echo $this->TRANSLATOR->translator('common_core', 'core'); ?></span></a>
			<div class="dropdown help_index" style="display: none;">
				<div class="arrow"></div>
				<div class="content">
					<?php if (isset($this->coreResources) && $this->coreResources) : ?>
					<?php $count = 0; ?>
					<?php foreach ($this->coreResources->resource as $index => $resource) : ?>
					<?php $temp = explode('_', (string)$resource->route); ?>
					<?php $module = $temp[0]; ?>
					<?php $controller = $temp[1]; ?>
					<?php $action = (isset($temp[2])) ? $temp[2] : 'index'; ?>
					<?php if ($this->ACL->isAllowed($action, $controller, $module)) : ?>
					<?php if ($count % 2 == 0) : ?>
					<div class="col w5">
					<?php else : ?>
					<div class="col w5 last">
					<?php endif; ?>
						<a href="<?php echo $this->url((string)$resource->route); ?>">
							<?php echo $this->TRANSLATOR->translator((string)$resource->lang_key, $module); ?>
						</a>
						<div class="clear"></div>
						<?php if (count($resource->task) > 0) : ?>
						<ul class="g_a_actions_menu">
							<?php foreach ($resource->task as $taskIndex => $task) : ?>
							<?php $temp = explode('_', (string)$task->route); ?>
							<?php $module = $temp[0]; ?>
							<?php $controller = $temp[1]; ?>
							<?php $action = (isset($temp[2])) ? $temp[2] : 'index'; ?>
							<?php if ($this->ACL->isAllowed($action, $controller, $module)) : ?>
							<li><a href="<?php echo $this->url((string)$task->route); ?>"><?php echo $this->TRANSLATOR->translator((string)$task->lang_key, $module); ?></a></li>
							<?php endif; ?>
							<?php endforeach; ?>
						</ul>
						<?php endif; ?>
						<hr />
					</div>
					<?php if ($count % 2 != 0) : ?>
					<div class="clear"></div>
					<?php endif; ?>
					<?php $count++; ?>
					<?php endif; ?>	
					<?php endforeach; ?>
					<?php endif; ?>
					<div class="clear"></div>
					<a class="button red right close"><small class="icon cross"></small><span><?php echo $this->TRANSLATOR->translator('common_close', 'core'); ?></span></a>
					<div class="clear"></div>
				</div>
			</div>
		</div>
		<div class="module buttons">
			<a href="" class="dropdown_button"><small class="icon polaroids"></small><span><?php echo $this->TRANSLATOR->translator('common_modules', 'core'); ?></span></a>
			<?php if (isset($this->wModules) && $this->wModules) : ?>
			<div class="dropdown help_index">
				<div class="arrow"></div>
				<div class="content">
					<?php $index = 0; ?>
					<?php foreach ($this->wModules as $module) : ?>
					<?php if (isset($module['resource']->task) && count($module['resource']->task) > 0) : ?>
					<?php if ($index % 2 == 0) : ?>
					<div class="col w5">
					<?php else : ?>
					<div class="col w5 last">
					<?php endif; ?>
						<a href="javascript: void(0);">
							<?php echo $this->TRANSLATOR->translator('about_' . $module['module_id'] . '_title', $module['module_id']); ?>
						</a>
						<div class="clear"></div>
						<?php if (isset($module['resource']->task) && count($module['resource']->task) > 0) : ?>
						<ul class="g_a_actions_menu">
							<?php foreach ($module['resource']->task as $taskIndex => $task) : ?>
							<?php $temp = explode('_', (string)$task->route); ?>
							<?php $module = $temp[0]; ?>
							<?php $controller = $temp[1]; ?>
							<?php $action = (isset($temp[2])) ? $temp[2] : 'index'; ?>
							<?php if ($this->ACL->isAllowed($action, $controller, $module)) : ?>
							<li><a href="<?php echo $this->url((string)$task->route); ?>"><?php echo $this->TRANSLATOR->translator((string)$task->lang_key, $module); ?></a></li>
							<?php endif; ?>
							<?php endforeach; ?>
						</ul>
						<?php endif; ?>
						<hr />
					</div>
					<?php if ($index % 2 != 0) : ?>
					<div class="clear"></div>
					<?php endif; ?>
					<?php $index++; ?>
					<?php endif; ?>
					<?php endforeach; ?>
					<div class="clear"></div>
					<a class="button red right close"><small class="icon cross"></small><span><?php echo $this->TRANSLATOR->translator('common_close', 'core'); ?></span></a>
					<div class="clear"></div>
				</div>
			</div>
			<?php endif; ?>
		</div>
		<div class="module buttons">
			<a class="dropdown_button" href="javascript: void(0);"><small class="icon v-card"></small><span><?php echo $this->TRANSLATOR->translator('widget_toolbox_title', 'core'); ?></span></a>
			<div class="dropdown help_index">
				<div class="arrow"></div>
				<div class="content w_15">
					<div class="col">
						<ul class="g_a_actions_menu">
							<?php foreach ($this->widgetsToolbox as $index => $toolbox) : ?>
							<li>
								<a href="javascript: void(0);" class="g_a_toolbox_menu" id="<?php echo $toolbox['module_id']; ?>_toolbox_<?php echo $toolbox['widget_id']; ?>">
									<?php echo $this->TRANSLATOR->widget('about_title', $toolbox['module_id'], $toolbox['widget_id']); ?>
								</a>
								<hr />
							</li>
							<?php endforeach; ?>
						</ul>
					</div>
					<div class="clear"></div>
					<a class="button red right close"><small class="icon cross"></small><span><?php echo $this->TRANSLATOR->translator('common_close', 'core'); ?></span></a>
					<div class="clear"></div>
				</div>
			</div>
		</div>
		<!--<div class="module buttons">
			<a class="module_button" href="<?php echo $this->url('core_user_profile'); ?>"><small class="icon single_user"></small><span><?php echo $this->TRANSLATOR->translator('common_profile', 'core'); ?></span></a>
		</div>-->
	</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
	/**
	 * Show toolbox
	 * @since 2.1.0
	 */
	$('a.g_a_toolbox_menu').click(function() {
		/**
		 * Close all toolbox
		 */
		$('.g_a_toolbox').remove();
		$('.close').click();
		var manager = Gio.Core.ToolBox.Manager.getInstance();
		manager.getToolbox($(this).attr('id'))
			   .setTitle($(this).text())
			   .setCurrentModule('<?php echo Gio_Core_Controller::getIntance()->getModuleName(); ?>')
			   .setLang('<?php echo $this->lang; ?>')
			   .show();
	});
});
</script>